% !Mode:: "TeX:UTF-8"
\documentclass[12pt,openright]{book}
\usepackage[a4paper,
  bindingoffset=1cm,
  left=2.5cm,
  right=2.5cm,
  top=3cm,
  bottom=4cm,
  footskip=1.5cm,
  twoside]{geometry}

\usepackage[square,super,comma,sort]{natbib}
%\setcitestyle{open={\ensuremath{^[}},close={\ensuremath{^]}}}
\usepackage{float}
\usepackage{calc}
\usepackage[font={bf},labelsep=quad]{caption}
\usepackage{amsmath}
\usepackage{amsfonts}
%\usepackage{verbatim}
\usepackage{makecell}
\usepackage{tikz}
\usetikzlibrary{%
    arrows,%
    shapes,%
    chains,%
    matrix,%
    positioning,%
    scopes%
}
\usepackage{calc}
\usepackage{doc}
\usepackage{setspace}
\onehalfspacing
%\doublespacing
\parskip 0.5\baselineskip
\usepackage{ifthen}
% set linkcolor to blue for ebook :)

%\usepackage[dvipdfmx,bookmarks=true,bookmarksnumbered=false,
%            colorlinks,linkcolor=black,
%            citecolor=black,urlcolor=black]{hyperref}

% 2013-1-8，删去dvipdfmx
\usepackage[bookmarks=true,bookmarksnumbered=false,
            colorlinks,linkcolor=black,
            citecolor=black,urlcolor=black]{hyperref}

%\usepackage[dotinlabels]{titletoc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength\headheight{15pt}
%\fancyhf{}
%\fancyhead{\thepage}
% 2013-1-8 请在这里设置奇数偶数页的页眉格式
%\fancyhead[LE,RO]{\thepage}
%\fancyhead[RE,LO]{\thesection}
%\fancyhead[RE,LO]{\XMUT@value@title }
\usepackage{multirow}
\usepackage{longtable}
\usepackage{arydshln}
\setlength\dashlinedash{5pt}
\setlength\dashlinegap{2pt}
\newcommand*{\dd}[1]{\,\ensuremath{\mathrm{d}#1}}
\newcommand*{\ddd}[2]{\,\ensuremath{\mathrm{d}#1\mathrm{d}#2}}
\newcommand*{\dddd}[3]{\,\ensuremath{\mathrm{d}#1\mathrm{d}#2\mathrm{d}#3}}
\usepackage{txfonts}
%\usepackage{mathptmx}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Times New Roman PS Std}
\setsansfont[Mapping=tex-text]{Mosquito Formal Std}
%\setsansfont[Mapping=tex-text]{Myriad Pro}
\setmonofont[Scale=0.8]{Lucida Sans Typewriter Std}

\usepackage{xunicode}
\usepackage{xltxtra}

%\usepackage{mathspec}
%\setmathsfont[Set=Latin]{Asana Math}
%\setmathsfont[Set=Greek]{Asana Math}
%\setmathsfont[Set=Symbols]{Asana Math}
\usepackage{indentfirst}
\usepackage{zhspacing}
\usepackage[fakebold]{zhfont}
% for chinese font:
\newfontfamily\zhpunctfont{Adobe Song Std}
\setzhmainfont{Adobe Song Std}
\setzhsansfont{Adobe Heiti Std}
\setzhmonofont{Adobe Kaiti Std}
% for Chinese Numbers :)
\usepackage{xCJKnumb}

\renewcommand\chaptermark[1]
{\markboth{第\xCJKnumber{\thechapter}章\hspace{2ex} #1}{}}
\renewcommand\sectionmark[1]
{\markright{\thesection\quad #1}}
% redefine names
%\newcommand\contentsname{Contents}
\renewcommand\contentsname{目\quad{}录}
\newcommand\econtentsname{Contents}
\renewcommand\listfigurename{插图目录}
\renewcommand\listtablename{表格目录}
\renewcommand\bibname{参考文献}
\renewcommand\indexname{索引}
\renewcommand\figurename{图}
\renewcommand\tablename{表}
\renewcommand\partname{部分}
\renewcommand\appendixname{附录}
% read common comands
\input{config/headcommon}

% start more DIY
\makeatletter
% for natbib
\renewcommand\NAT@citesuper[3]{\ifNAT@swa
\if*#2*\else#2\ \fi
\unskip\kern\p@\textsuperscript{\NAT@@open#1\NAT@@close}%
   \if*#3*\else\ #3\fi\else #1\fi\endgroup}

\renewcommand\textsuperscript[1]{\mbox{$^{\mbox{\scriptsize#1}}$}}
% for chapter
\newcommand\@chaplable[1]{第\xCJKnumber{#1}章}
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}
\renewcommand\@chapter[3][default]{%
                    \ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{第\thechapter 章}%
                         \addcontentsline{toc}{chapter}%
                            {\protect\numberline{\@chaplable{\thechapter}}\hspace{-1.1em}#1}%
                         \addcontentsline{eoc}{chapter}%
                         {\protect\numberline{\textsc{\chaptername}\ \thechapter}#3}%
                       \else
                         \addcontentsline{toc}{chapter}{#1}%
                         \addcontentsline{eoc}{chapter}{#3}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                      \addcontentsline{eoc}{chapter}{#3}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\def\@makechapterhead#1{%
  \vspace*{10\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \centering \sffamily \bfseries \xiaosan  \@chaplable{\thechapter}\hspace{2ex}
      \fi
    \fi
    \interlinepenalty\@M
    #1\par\nobreak
    \vskip 10\p@
  }}

\def\@schapter#1{%
  \if@twocolumn
    \@topnewpage[\@makeschapterhead{#1}]%
  \else
    \@makeschapterhead{#1}%
    \@afterheading
  \fi%
}

\def\@makeschapterhead#1{%
  \vspace*{10\p@}%
  {\parindent \z@ \raggedright
    \interlinepenalty\@M
    \centering \sffamily \bfseries \xiaosan #1\par\nobreak
    \vskip 10\p@
  }%
}

\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{7em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \sffamily\bfseries\sihao
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss\rmfamily #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi%
}
\renewcommand*\l@section[2]{\@dottedtocline{1}{1.5em}{2.3em}%
  {\sffamily\bfseries\xiaosi #1}{#2}}
\renewcommand*\l@subsection[2]{\@dottedtocline{2}{3.8em}{3.2em}%
  {\rmfamily\bfseries\xiaosi #1}{#2}}
% for section
\renewcommand\section[2]{%
  \refstepcounter{section}
  \addcontentsline{toc}{section}%
    {\protect\numberline{\thesection}#1}%
  \addcontentsline{eoc}{section}%
    {\protect\numberline{\thesection}#2}%
  \sectionmark{#1}%
  \par\vspace{3.5ex \@plus 1ex \@minus -.2ex}%
  {%
    \parindent \z@ \raggedright
    \interlinepenalty\@M
    \sffamily \bfseries \sihao \thesection \hspace{1em}#1\par\nobreak%
  }%
  \vspace{2.3ex \@plus 0.2ex}
}
%
\renewcommand\subsection[2]{%
  \refstepcounter{subsection}
  \addcontentsline{toc}{subsection}%
    {\protect\numberline{\thesubsection}#1}%
  \addcontentsline{eoc}{subsection}%
    {\protect\numberline{\thesubsection}#2}%
  \par\vspace{3.25ex\@plus 1ex \@minus -.2ex}%
  {%
    \parindent \z@ \raggedright
    \interlinepenalty\@M
    \sffamily \bfseries \xiaosi \thesubsection \hspace{1em}#1\par\nobreak%
  }%
  \vspace{1.5ex \@plus 0.2ex}
}
%
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\sffamily\bfseries\xiaosi}}
%

\renewcommand\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
  \thispagestyle{empty}%
  \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
  
%%用于产生没有编号但在目录中列出的章。
%% \phantomsection is the anchor hyperref needed to make a bookmark,
%% without it, hyerref would throw out warnings.
%% typeset Chinese Chapter, then list it in toc and eoc
\newcommand\CNchapter[2]{%
  \chapter*{\phantomsection %
  \center{#1}}%
  \markboth{#1}{}%
  \addcontentsline{toc}{chapter}{#1}%
  \addcontentsline{eoc}{chapter}{#2}%
}
%% typeset English Chapter, then list it in toc and eoc
\newcommand\ENchapter[2]{%
  \chapter*{\phantomsection %
  \center{#2}}%
  \markboth{#2}{}%
  \addcontentsline{toc}{chapter}{#1}%
  \addcontentsline{eoc}{chapter}{#2}%
}
%% Chinese Chapter only in toc
\newcommand\Cchapter[1]{%
  \chapter*{\phantomsection %
    \center{#1}}%
  \markboth{#1}{}%
  \addcontentsline{toc}{chapter}{#1}%
}
%% English Chapter only in eoc
\newcommand\Echapter[1]{%
  \chapter*{\phantomsection %
  \center{#1}}%
  \markboth{#1}{}%
  \addcontentsline{eoc}{chapter}{#1}%
}
%

%%============================摘要===========================%%

%%中文摘要。
\newenvironment{abstract}
  {\Cchapter{\texorpdfstring{摘\quad 要}{摘要}}
  \pagenumbering{Roman}
  \setcounter{page}{1}}
  {}
%%中文关键词。
\newcommand\keywords[1]{%
  \vspace{2ex}\noindent{\sffamily \bfseries 关键词：} #1}

  
%%英文摘要。
\newenvironment{englishabstract}
  {\ENchapter{英文摘要}{Abstract}%
  \parindent 0pt}
  {}
%%英文关键词。
\newcommand\englishkeywords[1]{%
  \vspace{2ex}\noindent{\sffamily \bfseries Keywords:} #1}

%% Thanks
\renewenvironment{thanks}
  {\CNchapter{\texorpdfstring{致\quad{}谢}{致谢}}{Thanks}}
  {\ifodd\c@page%
    \newpage\thispagestyle{empty}
    \hbox{}\fi }
%% publications, options is the number of publications
\newenvironment{publications}[1]
  {\CNchapter{\XMUT@value@degree 期间发表的论文}{Publications as the Degree Candidate}%
    \list{\@biblabel{\@arabic\c@enumi}}%
      {\settowidth\labelwidth{\@biblabel{#1}}%
        \leftmargin\labelwidth
        \advance\leftmargin\labelsep
        \@openbib@code
        \usecounter{enumi}%
        \let\p@enumi\@empty
        \renewcommand\theenumi{\@arabic\c@enumi}}%
    \sloppy
    \clubpenalty4000
    \@clubpenalty \clubpenalty
    \widowpenalty4000%
    \sfcode`\.\@m}
 {\def\@noitemerr
   {\@latex@warning{Empty `publications' environment}}%
  \endlist}

%%======================参考文献======================%%

%%修改thebibliography 的定义以在目录中加入相应条目。
\renewenvironment{thebibliography}[1]
  {\CNchapter{\bibname}{References}%
	  \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
	  \wuhao%用比正文小一号的字体排印参考文献内容
	  \list{\@biblabel{\@arabic\c@enumiv}}%
		   {\settowidth\labelwidth{\@biblabel{#1}}%
			\leftmargin\labelwidth
			\advance\leftmargin\labelsep
			\@openbib@code
			\usecounter{enumiv}%
			\let\p@enumiv\@empty
			\renewcommand\theenumiv{\@arabic\c@enumiv}}%
	  \sloppy
	  \clubpenalty4000
	  \@clubpenalty \clubpenalty
	  \widowpenalty4000%
	  \sfcode`\.\@m}
	 {\def\@noitemerr
	   {\@latex@warning{Empty `thebibliography' environment}}%
	  \endlist}

%%===========================目录==============================%%

%%设置目录格式。
\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \begingroup
    \parskip 0pt
    \Cchapter{\texorpdfstring{\contentsname}{目录}}%
    \@starttoc{toc}%
    \ENchapter{英文目录}{\econtentsname}%
    \@starttoc{eoc}%
    \endgroup
    \if@restonecol\twocolumn\fi%
    \cleardoublepage%
    }

%%====================封面==========================
\newcommand\underlinewidth[2][50pt]{\underline{\parbox[t]{#1}{\centering#2}}}
%
\renewcommand\maketitle{%
  \begin{titlepage}
    \addtolength{\oddsidemargin}{-0.5cm}
    \begin{center}
      \parskip 0pt
      {\rmfamily\bfseries\xiaosi
        学校编码：~10384
          \hfill
        分类号
        \underlinewidth{\XMUT@value@classification}
        密级
        \underlinewidth{\XMUT@value@confidential}
      \vskip 0pt
        学号：
        \XMUT@value@studentsn
          \hfill
        UDC~\underlinewidth{\XMUT@value@UDC}}
      \vskip \stretch{2}
      \includegraphics[width=5.8cm]{figures/xmu-zi-3d-600dpi}\\
      \vskip \stretch{2}
      {\rmfamily\bfseries\xiaoer
        \fillparbox{198pt}{\XMUT@value@degree%
        学位论文}\\
      }
      \vskip \stretch{2}
        {\sffamily\bfseries
          \erhao \XMUT@value@title
        }
      \vskip \stretch{1}
        {\rmfamily\bfseries
          \sanhao \XMUT@value@englishtitle
        }
      \vskip \stretch{2}
      \newlength{\XMUT@len@author}
      \settowidth{\XMUT@len@author}{\XMUT@value@author}
      \setlength{\XMUT@len@author}{\XMUT@len@author * \real{1.8}}
        {\ttfamily\mdseries\xiaoer
          \fillparbox{\XMUT@len@author}{\XMUT@value@author}
        }
      \vskip \stretch{1}
      %\def\tabcolsep{1pt}
      %\def\arraystretch{1.5}
      \newlength{\XMUT@len@advisor}
      \settowidth{\XMUT@len@advisor}{\XMUT@value@advisor\hspace*{1.5em}\XMUT@value@advisortitle}
      %% length for ~~
      %\addtolength{\XMUT@len@advisor}{30pt}
      \setlength{\XMUT@len@advisor}{\ifdim \XMUT@len@advisor > 84pt \XMUT@len@advisor
        \else 84pt
        \fi}

      {\ttfamily\mdseries\sihao
        \begin{tabular}{rl}
          \parbox[t]{6cm}{\hfill\fillparbox{84pt}{指导教师姓名}:}&%
            \parbox[t]{6cm}{~\fillparbox{\XMUT@len@advisor}{\XMUT@value@advisor~\XMUT@value@advisortitle}\hfill}\\
          \fillparbox{84pt}{专业名称}:&~\fillparbox{\XMUT@len@advisor}{\XMUT@value@major}\\
          \fillparbox{84pt}{论文提交日期}:&%
            ~\fillparbox{\XMUT@len@advisor}{\textrm{\XMUT@value@submitdate@year}~年%
              ~\textrm{\XMUT@value@submitdate@month}~月}\\
              %\makebox[3ex]{\textrm{\XMUT@value@submitdate@day}}日\\
          \fillparbox{84pt}{论文答辩时间}:&%
            ~\fillparbox{\XMUT@len@advisor}{\textrm{\XMUT@value@defenddate@year}~年%
              ~\textrm{\XMUT@value@defenddate@month}~月}\\
            %\makebox[3ex]{\textrm{\XMUT@value@defenddate@day}}日\\
          \fillparbox{84pt}{学位授予日期}:&%
            ~\fillparbox{\XMUT@len@advisor}{\textrm{\XMUT@value@grantdate@year}~年%
              ~\textrm{\XMUT@value@grantdate@month}~月}\\
              %\makebox[3ex]{\textrm{\XMUT@value@grantdate@day}}日
        \end{tabular}
      }
      \vskip \stretch{2}
      \rmfamily\mdseries\sihao
      \begin{tabular}{rl}
        \parbox[t]{7cm}{\hfill}&\parbox[t]{7cm}{
                \fillparbox{98pt}{答辩委员会主席}:~%
		\underlinewidth[75pt]{\texttt{\XMUT@value@chairman}}\hfill\\
                \fillparbox{42pt}{评阅人}:~\underlinewidth[131pt]{\texttt{\XMUT@value@appraiser}}\hfill
        }
      \end{tabular}
      \vskip \stretch{2.5}
        \XMUT@value@submitdate@year~~年%
          ~~\XMUT@value@submitdate@month~~月
          %\XMUT@value@submitdate@day 日
      \vskip \stretch{2}
    \end{center}
  \end{titlepage}
  %\cleardoublepage
  % 版权声明
  \chapter*{\centering{\sffamily\bfseries\xiaoer 厦门大学学位论文原创性声明}}
  \thispagestyle{empty}
  \begin{doublespace}
    \rmfamily\mdseries\sihao
    本人呈交的学位论文是本人在导师指导下，独立完成的研究成果。本人在论文写作
    中参考其他个人或集体已经发表的研究成果，均在文中以适当方式明确标明，并符
    合法律规范和《厦门大学研究生学术活动规范（试行）》。
    
    另外，该学位论文为（\@ifundefined{XMUT@value@team}%
    {\parbox[t]{200pt}{\quad}}{\XMUT@value@team}）课题（组）的研究成果，获得
    （\@ifundefined{XMUT@value@fundteam}{\parbox[t]{120pt}{\quad}}%
    {\XMUT@value@fundteam}）课题（组）经费或实验室的资助，
    在（\@ifundefined{XMUT@value@lab}{\parbox[t]{120pt}{\quad}}%
    {\XMUT@value@lab}）实验室完成。（请在以上括号内填写课题或课题组负责人或
    实验室名称，未有此项声明内容的，可以不作特别声明。）

    \vspace{20pt}

    \hfill 声明人（签名）：\hspace*{4cm}\\
    \vspace{-10pt} 
    \hfill 年\hspace{26pt}月\hspace{26pt}日\hspace*{2cm}
  
  \end{doublespace}

  %\cleardoublepage
  \newcommand\XMUT@checkmark{\fillparbox{2em}{\centering\ensuremath{\checkmark}}}
  \chapter*{\centering{\sffamily\bfseries\xiaoer 厦门大学学位论文著作权使用声明}}
  \thispagestyle{empty}
  \begin{onehalfspace}
    \rmfamily\mdseries\sihao
        本人同意厦门大学根据《中华人民共和国学位条例暂行实施办法》等规定保留和使
    用此学位论文，并向主管部门或其指定机构送交学位论文（包括纸质版和电子版），
    允许学位论文进入厦门大学图书馆及其数据库被查阅、借阅。本人同意厦门大学将
    学位论文加入全国博士、硕士学位论文共建单位数据库进行检索，将学位论文的标
    题和摘要汇编出版，采用影印、缩印或者其它方式合理复制学位论文。
    
    本学位论文属于：

    （\ifthenelse{\boolean{XMUT@boolean@confidential}}{\XMUT@checkmark}{\hspace{2em}}）
    \quad 1.\quad 经厦门大学保密委员会审查核定的保密学位论文，于%
    \@ifundefined{XMUT@value@confidentialdate@year}
    {\hspace{60pt}}
    {\XMUT@value@confidentialdate@year}年%
    \@ifundefined{XMUT@value@confidentialdate@month}
    {\hspace{28pt}}
    {\XMUT@value@confidentialdate@month}月%
    \@ifundefined{XMUT@value@confidentialdate@day}
    {\hspace{28pt}}
    {\XMUT@value@confidentialdate@day}日解密，解密后适用上述授权。


    （\ifthenelse{\boolean{XMUT@boolean@confidential}}{\hspace{2em}}{\XMUT@checkmark}）
    \quad 2.\quad 不保密，适用上述授权。

        （请在以上相应括号内打“\ensuremath{\checkmark}或”填上相应内容。保密学位论文应是已经厦门大学
    保密委员会审定过的学位论文，未经厦门大学保密委员会审定的学位论文均为公开
    学位论文。此声明栏不填写的，默认为公开学位论文，均适用上述授权。）

    \vspace{20pt}

    \hfill 声明人（签名）：\hspace*{4cm}\\
    \vspace{-10pt} 
    \hfill 年\hspace{26pt}月\hspace{26pt}日\hspace*{2cm}
  
  \end{onehalfspace}
  %\clearpage
}
\makeatother

%---------------------------- 数学公式设置 ------------------------------%
%\setlength{\abovedisplayskip}{6pt plus1pt minus1pt}     %公式前的距离
%\setlength{\belowdisplayskip}{6pt plus1pt minus1pt}     %公式后面的距离
\setlength{\arraycolsep}{4pt}   %在一个array中列之间的空白长度, 因为原来的太宽了

% \eqnarray如果很长，影响分栏、换行和分页（整块挪动，造成页面空白），
% 可以设置成为自动调整模式
\allowdisplaybreaks[4]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%下面这组命令使浮动对象的缺省值稍微宽松一点，从而防止幅度
%对象占据过多的文本页面，也可以防止在很大空白的浮动页上放置
%很小的图形。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.80}

\pagenumbering{roman}
